import java.util.*;
public class Solution {
    public static int method(int[] a){
        int max = 0;
        //left[] right[]
        int[] left = new int[a.length];
        int[] right = new int[a.length];

        for(int i=0; i<a.length ;i++){
            int leftIndex=0;
            while(i-leftIndex>=0 && a[i-leftIndex]>=a[i]){
                leftIndex++;
            }
            left[i] = leftIndex;

            int rightIndex=0;
            while(i+rightIndex<a.length&&a[i+rightIndex]>=a[i]){
                rightIndex++;
            }
            right[i] = rightIndex;
        }

        for(int i=0; i<a.length; i++){
            if(a[i]*(left[i]+right[i]-1)>max)
                max = a[i]*(left[i]+right[i]-1);
        }
        return max;
    }
    public static void main(String args[]){
       Scanner s = new Scanner(System.in);
       int i = s.nextInt();
       int[] a = new int[i];
       for(int k=0;k<i;k++)
           a[k] = s.nextInt();
//       String a = s.nextLine();
//       int i =6;
//       int[] a = {2,1,5,6,2,3};
       System.out.println(method(a));

    }

}

